package com.dd.web.securities.controller;

import com.alibaba.fastjson.JSONObject;
import com.dd.common.entity.CommonResult;
import com.dd.web.securities.constant.ExchangeEnum;
import com.dd.web.securities.entity.Candle.CandleData;
import com.dd.web.securities.entity.IndiceLineDataVo;
import com.dd.web.securities.service.IndicesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 证券指数
 */
@Api(description="获取上证指数",tags="IndicesController")
@RestController
@RequestMapping("/indices/")
public class IndicesController {

    @Autowired
    private IndicesService indicesService;

    @ApiOperation("查询上证指数")
    @GetMapping("query")
    public CommonResult<IndiceLineDataVo> queryIndices(){
        List<IndiceLineDataVo> dataVoList = indicesService.queryLineDataList();
        CommonResult result = CommonResult.success(dataVoList);
        System.out.print(JSONObject.toJSONString(result));
        return result;
    }

    @ApiOperation("查询当天分时图交易数据")
    @GetMapping("today")
    public CommonResult<CandleData> queryToday(){
        CandleData dataVoList = indicesService.queryCandleData(ExchangeEnum.SHENZHENG,"000016");
        CommonResult result = CommonResult.success(dataVoList);
        System.out.print(JSONObject.toJSONString(result));
        return result;
    }

}
